#ifndef APP_SOCKET_H
#define APP_SOCKET_H

#include <unistd.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <sys/types.h>          /* See NOTES */
#include <sys/socket.h>
#include <string>

class Socket
{
public:
    Socket(/* args */);
    ~Socket();

    int getSocketFd();
    int CreatSocket(int domain, int type, int protocol = 0);
    void CloseSocket();
    int Bind(struct sockaddr_in *my_addr, socklen_t addrlen = sizeof(struct sockaddr_in));
    int Listen(int backlog);
    int Accept(struct sockaddr_in *addr, socklen_t *addrlen);
    int Connect(const struct sockaddr_in *addr, socklen_t addrlen);
    ssize_t Read(int fd, void *buf, size_t count);
    ssize_t Readn(int fd, void *buf, size_t count);
    ssize_t Readline(int fd, void *buf);
    ssize_t Write(int fd, const void *buf, size_t count);
    ssize_t Writen(int fd, const void *buf, size_t count);
    ssize_t Send(int fd, const void *__buf, size_t __n, int __flags);
    ssize_t Recv(int fd, void *__buf, size_t __n, int __flags);

    static char* GetHostByName(const char* name);

protected:
    int sockfd;
};


#endif /* APP_SOCKET_H */
